package com.guanzi.netty.protocol;

import io.netty.handler.codec.LengthFieldBasedFrameDecoder;

/**
 * 处理黏包半包问题
 */
public class ProcotolFrameDecoder extends LengthFieldBasedFrameDecoder {

    public ProcotolFrameDecoder() {
        // 01 02 03 04 01 00 00 00 00 00 00 ff (00 00 00 ed) 长度字段
        // 最大帧长度1024， 长度字段偏移量12字节，长度本身占4字节，长度和内容中间没有要偏移留空的字节，读取后不跨过任何一个字节（因为解码器自己解析所有内容）
        this(1024, 12, 4, 0, 0);
    }

    public ProcotolFrameDecoder(int maxFrameLength, int lengthFieldOffset, int lengthFieldLength, int lengthAdjustment, int initialBytesToStrip) {
        super(maxFrameLength, lengthFieldOffset, lengthFieldLength, lengthAdjustment, initialBytesToStrip);
    }
}
